package com.cskaoyan.jdbc.datasource;

import com.cskaoyan.jdbc.datasource.c3p0.C3p0Utils;
import com.cskaoyan.jdbc.datasource.dbcp.DBCPUtils;
import com.cskaoyan.jdbc.datasource.druid.DruidUtils;
import com.cskaoyan.jdbc.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2022/05/13 17:29
 *
 * @author ciggar
 *
 *
 */
public class DatasourceDemo2 {

    public static void main(String[] args) throws SQLException {

        Connection connection = DruidUtils.getConnection();


        Statement statement = connection.createStatement();

        ResultSet resultSet = statement.executeQuery("select * from account");

        while (resultSet.next()) {
            int id = resultSet.getInt("id");
            String name = resultSet.getString("name");
            System.out.println("id:" + id + ", name:" +name);
        }

        // 关闭资源
        JDBCUtils.close(connection,statement,resultSet);


    }
}
